﻿Imports System.Data.SqlClient

Public Class clsE_MatrizEvaluación
    Private mintIdMatriz As Integer
    Private mintIdAutobus As Integer
    Private mstrNoEconomico As String
    Private mintIdOperador As Integer
    Private mstrNombreOperador As String
    Private mdatFecha As Date
    Private mintDia As Integer
    Private mintMes As Integer
    Private mintAnio As Integer
    Private mdblServicios As Double
    Private mdblPuntualidad As Double
    Private mdblPresentacion As Double
    Private mdblRendimiento As Double
    Private mdblVentas As Double
    Private mdblBloqueos As Double
    Private mdblTotal As Double
    Public Property IdMatriz() As Integer
        Get
            Return mintIdMatriz
        End Get
        Set(ByVal value As Integer)
            mintIdMatriz = value
        End Set
    End Property
    Public Property IdAutobus() As Integer
        Get
            Return mintIdAutobus
        End Get
        Set(ByVal value As Integer)
            mintIdAutobus = value
        End Set
    End Property

    Public Property NoEconomico() As String
        Get
            Return mstrNoEconomico
        End Get
        Set(ByVal value As String)
            mstrNoEconomico = value
        End Set
    End Property
    Public Property IdOperador() As Integer
        Get
            Return mintIdOperador
        End Get
        Set(ByVal value As Integer)
            mintIdOperador = value
        End Set
    End Property
    Public Property NombreOperador() As String
        Get
            Return mstrNombreOperador
        End Get
        Set(ByVal value As String)
            mstrNombreOperador = value
        End Set
    End Property
    Public Property Fecha() As Date
        Get
            Return mdatFecha
        End Get
        Set(ByVal value As Date)
            mdatFecha = value
        End Set
    End Property
    Public Property Dia() As Integer
        Get
            Return mintDia
        End Get
        Set(ByVal value As Integer)
            mintDia = value
        End Set
    End Property
    Public Property Mes() As Integer
        Get
            Return mintMes
        End Get
        Set(ByVal value As Integer)
            mintMes = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property
    Public Property Servicios() As Double
        Get
            Return mdblServicios
        End Get
        Set(ByVal value As Double)
            mdblServicios = value

        End Set
    End Property
    Public Property Puntualidad() As Double
        Get
            Return mdblPuntualidad
        End Get
        Set(ByVal value As Double)
            mdblPuntualidad = value

        End Set
    End Property
    Public Property Presentacion() As Double
        Get
            Return mdblPresentacion
        End Get
        Set(ByVal value As Double)
            mdblPresentacion = value

        End Set
    End Property
    Public Property Rendimiento() As Double
        Get
            Return mdblRendimiento
        End Get
        Set(ByVal value As Double)
            mdblRendimiento = value

        End Set
    End Property
    Public Property Ventas() As Double
        Get
            Return mdblVentas
        End Get
        Set(ByVal value As Double)
            mdblVentas = value

        End Set
    End Property
    Public Property Bloqueos() As Double
        Get
            Return mdblBloqueos
        End Get
        Set(ByVal value As Double)
            mdblBloqueos = value

        End Set
    End Property
   
    Public Property Total() As Double
        Get
            Return mdblTotal
        End Get
        Set(ByVal value As Double)
            mdblTotal = value
        End Set
    End Property
    Public Sub New()
        mintIdMatriz = 0
        mintIdAutobus = 0
        mstrNoEconomico = ""
        mintIdOperador = 0
        mstrNombreOperador = ""
        mdatFecha = Now()
        mintDia = 0
        mintMes = 0
        mintAnio = 0
        mdblServicios = 0
        mdblPuntualidad = 0
        mdblPresentacion = 0
        mdblRendimiento = 0
        mdblVentas = 0
        mdblBloqueos = 0
        mdblTotal = 0
    End Sub
    Public Sub Insertarold()
        Dim sql As String = "Insert Into E_MatrizEvaluacion (" & _
                            "IdAutobus," & _
                            "NoEconomico," & _
                            "IdOperador," & _
                            "NombreOperador," & _
                            "Fecha," & _
                            "Dia," & _
                            "Mes," & _
                            "Anio," & _
                            "Servicios," & _
                            "Puntualidad," & _
                            "Presentacion," & _
                            "Rendimiento," & _
                            "Ventas," & _
                            "Bloqueos," & _
                            "Total) " & _
                            "VALUES (" & _
                            "@IdAutobus," & _
                            "substring(@NoEconomico,1,100)," & _
                            "@IdOperador," & _
                            "substring(@NombreOperador,1,150)," & _
                            "@Fecha," & _
                            "@Dia," & _
                            "@Mes," & _
                            "@Anio," & _
                            "@Servicios," & _
                            "@Puntualidad," & _
                            "@Presentacion," & _
                            "@Rendimiento," & _
                            "@Ventas," & _
                            "@Bloqueos," & _
                            "@Total) "

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdAutobus", mintIdAutobus)
        Command.Parameters.AddWithValue("NoEconomico", mstrNoEconomico)
        Command.Parameters.AddWithValue("IdOperador", mintIdOperador)
        Command.Parameters.AddWithValue("NombreOperador", mstrNombreOperador)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        Command.Parameters.AddWithValue("Dia", mintDia)
        Command.Parameters.AddWithValue("Mes", mintMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Servicios", mdblServicios)
        Command.Parameters.AddWithValue("Puntualidad", mdblPuntualidad)
        Command.Parameters.AddWithValue("Presentacion", mdblPresentacion)
        Command.Parameters.AddWithValue("Rendimiento", mdblRendimiento)
        Command.Parameters.AddWithValue("Ventas", mdblVentas)
        Command.Parameters.AddWithValue("Bloqueos", mdblBloqueos)
        Command.Parameters.AddWithValue("Total", mdblTotal)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro de evaluación", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
    Sub Insertar()
        Dim sql As String = "Insert Into E_MatrizEvaluacion (" & _
                           "IdAutobus," & _
                           "NoEconomico," & _
                           "IdOperador," & _
                           "NombreOperador," & _
                           "Fecha," & _
                           "Dia," & _
                           "Mes," & _
                           "Anio," & _
                           "Servicios," & _
                           "Puntualidad," & _
                           "Presentacion," & _
                           "Rendimiento," & _
                           "Ventas," & _
                           "Bloqueos," & _
                           "Total) " & _
                           "VALUES (" & _
                           "@IdAutobus," & _
                           "substring(@NoEconomico,1,100)," & _
                           "@IdOperador," & _
                           "substring(@NombreOperador,1,150)," & _
                           "@Fecha," & _
                           "@Dia," & _
                           "@Mes," & _
                           "@Anio," & _
                           "@Servicios," & _
                           "@Puntualidad," & _
                           "@Presentacion," & _
                           "@Rendimiento," & _
                           "@Ventas," & _
                           "@Bloqueos," & _
                           "@Total) "

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdAutobus", mintIdAutobus)
        Command.Parameters.AddWithValue("NoEconomico", mstrNoEconomico)
        Command.Parameters.AddWithValue("IdOperador", mintIdOperador)
        Command.Parameters.AddWithValue("NombreOperador", mstrNombreOperador)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        Command.Parameters.AddWithValue("Dia", mintDia)
        Command.Parameters.AddWithValue("Mes", mintMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Servicios", mdblServicios)
        Command.Parameters.AddWithValue("Puntualidad", mdblPuntualidad)
        Command.Parameters.AddWithValue("Presentacion", mdblPresentacion)
        Command.Parameters.AddWithValue("Rendimiento", mdblRendimiento)
        Command.Parameters.AddWithValue("Ventas", mdblVentas)
        Command.Parameters.AddWithValue("Bloqueos", mdblBloqueos)
        Command.Parameters.AddWithValue("Total", mdblTotal)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro de evaluación", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
    Sub Actualizar()
        Dim strSqlQry As String
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        strSqlQry = "Update E_MatrizEvaluacion Set " & _
                            "IdAutobus=@IdAutobus," & _
                            "NoEconomico=substring(@NoEconomico,1,50)," & _
                            "IdOperador=@IdOperador," & _
                            "NombreOperador=substring(@NombreOperador,1,50)," & _
                            "Fecha=@Fecha," & _
                            "Dia=@Dia," & _
                            "Mes=@Mes," & _
                            "Anio=@Anio," & _
                            "Servicios=@Servicios," & _
                            "Puntualidad=@Puntualidad," & _
                            "Presentacion=@Presentacion," & _
                            "Rendimiento=@Rendimiento," & _
                            "Ventas=@Ventas," & _
                            "Bloqueos=@Bloqueos," & _
                            "Total=@Total " & _
                            " Where IdMatriz=@IdMatriz"


        Dim Command As New SqlCommand(strSqlQry, cnConn)
        Command.Parameters.AddWithValue("IdMatriz", mintIdMatriz)
        Command.Parameters.AddWithValue("IdAutobus", mintIdAutobus)
        Command.Parameters.AddWithValue("NoEconomico", mstrNoEconomico)
        Command.Parameters.AddWithValue("IdOperador", mintIdOperador)
        Command.Parameters.AddWithValue("NombreOperador", mstrNombreOperador)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        Command.Parameters.AddWithValue("Dia", mintDia)
        Command.Parameters.AddWithValue("Mes", mintMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Servicios", mdblServicios)
        Command.Parameters.AddWithValue("Puntualidad", mdblPuntualidad)
        Command.Parameters.AddWithValue("Presentacion", mdblPresentacion)
        Command.Parameters.AddWithValue("Rendimiento", mdblRendimiento)
        Command.Parameters.AddWithValue("Ventas", mdblVentas)
        Command.Parameters.AddWithValue("Bloqueos", mdblBloqueos)
        Command.Parameters.AddWithValue("Total", mdblTotal)

        cnConn.Open()

        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible actualizar el registro de evaluación", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If



    End Sub
    Sub ActualizadesdeServicios()
        Dim strSqlQry As String
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        strSqlQry = "Update E_MatrizEvaluacion Set " & _
                            "IdAutobus=@IdAutobus," & _
                            "NoEconomico=substring(@NoEconomico,1,50)," & _
                            "IdOperador=@IdOperador," & _
                            "NombreOperador=substring(@NombreOperador,1,50)," & _
                            "Fecha=@Fecha," & _
                            "Dia=@Dia," & _
                            "Mes=@Mes," & _
                            "Anio=@Anio," & _
                            "Servicios=@Servicios," & _
                            "Puntualidad=@Puntualidad," & _
                            "Presentacion=@Presentacion," & _
                            "Total=@Total " & _
                            " Where IdMatriz=@IdMatriz"


        Dim Command As New SqlCommand(strSqlQry, cnConn)
        Command.Parameters.AddWithValue("IdMatriz", mintIdMatriz)
        Command.Parameters.AddWithValue("IdAutobus", mintIdAutobus)
        Command.Parameters.AddWithValue("NoEconomico", mstrNoEconomico)
        Command.Parameters.AddWithValue("IdOperador", mintIdOperador)
        Command.Parameters.AddWithValue("NombreOperador", mstrNombreOperador)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        Command.Parameters.AddWithValue("Dia", mintDia)
        Command.Parameters.AddWithValue("Mes", mintMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Servicios", mdblServicios)
        Command.Parameters.AddWithValue("Puntualidad", mdblPuntualidad)
        Command.Parameters.AddWithValue("Presentacion", mdblPresentacion)
        Command.Parameters.AddWithValue("Rendimiento", mdblRendimiento)
        Command.Parameters.AddWithValue("Ventas", mdblVentas)
        Command.Parameters.AddWithValue("Bloqueos", mdblBloqueos)
        Command.Parameters.AddWithValue("Total", mdblTotal)

        cnConn.Open()

        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible actualizar el registro de evaluación", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If



    End Sub
    Sub ActualizadesdeVentas()
        Dim strSqlQry As String
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        strSqlQry = "Update E_MatrizEvaluacion Set " & _
                            "IdAutobus=@IdAutobus," & _
                            "NoEconomico=substring(@NoEconomico,1,50)," & _
                            "IdOperador=@IdOperador," & _
                            "NombreOperador=substring(@NombreOperador,1,50)," & _
                            "Fecha=@Fecha," & _
                            "Dia=@Dia," & _
                            "Mes=@Mes," & _
                            "Anio=@Anio," & _
                            "Ventas=@Ventas," & _
                            "Bloqueos=@Bloqueos," & _
                            "Total=@Total " & _
                            " Where IdMatriz=@IdMatriz"


        Dim Command As New SqlCommand(strSqlQry, cnConn)
        Command.Parameters.AddWithValue("IdMatriz", mintIdMatriz)
        Command.Parameters.AddWithValue("IdAutobus", mintIdAutobus)
        Command.Parameters.AddWithValue("NoEconomico", mstrNoEconomico)
        Command.Parameters.AddWithValue("IdOperador", mintIdOperador)
        Command.Parameters.AddWithValue("NombreOperador", mstrNombreOperador)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        Command.Parameters.AddWithValue("Dia", mintDia)
        Command.Parameters.AddWithValue("Mes", mintMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Servicios", mdblServicios)
        Command.Parameters.AddWithValue("Puntualidad", mdblPuntualidad)
        Command.Parameters.AddWithValue("Presentacion", mdblPresentacion)
        Command.Parameters.AddWithValue("Rendimiento", mdblRendimiento)
        Command.Parameters.AddWithValue("Ventas", mdblVentas)
        Command.Parameters.AddWithValue("Bloqueos", mdblBloqueos)
        Command.Parameters.AddWithValue("Total", mdblTotal)

        cnConn.Open()

        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible actualizar el registro de evaluación", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If



    End Sub
    Sub ActualizardesdeDiesel()
        Dim strSqlQry As String
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        strSqlQry = "Update E_MatrizEvaluacion Set " & _
                            "IdAutobus=@IdAutobus," & _
                            "NoEconomico=substring(@NoEconomico,1,50)," & _
                            "IdOperador=@IdOperador," & _
                            "NombreOperador=substring(@NombreOperador,1,50)," & _
                            "Fecha=@Fecha," & _
                            "Dia=@Dia," & _
                            "Mes=@Mes," & _
                            "Anio=@Anio," & _
                            "Rendimiento=@Rendimiento," & _
                            "Total=@Total " & _
                            " Where IdMatriz=@IdMatriz"


        Dim Command As New SqlCommand(strSqlQry, cnConn)
        Command.Parameters.AddWithValue("IdMatriz", mintIdMatriz)
        Command.Parameters.AddWithValue("IdAutobus", mintIdAutobus)
        Command.Parameters.AddWithValue("NoEconomico", mstrNoEconomico)
        Command.Parameters.AddWithValue("IdOperador", mintIdOperador)
        Command.Parameters.AddWithValue("NombreOperador", mstrNombreOperador)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        Command.Parameters.AddWithValue("Dia", mintDia)
        Command.Parameters.AddWithValue("Mes", mintMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Servicios", mdblServicios)
        Command.Parameters.AddWithValue("Puntualidad", mdblPuntualidad)
        Command.Parameters.AddWithValue("Presentacion", mdblPresentacion)
        Command.Parameters.AddWithValue("Rendimiento", mdblRendimiento)
        Command.Parameters.AddWithValue("Ventas", mdblVentas)
        Command.Parameters.AddWithValue("Bloqueos", mdblBloqueos)
        Command.Parameters.AddWithValue("Total", mdblTotal)

        cnConn.Open()

        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible actualizar el registro de evaluación", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If



    End Sub
End Class
